package com.mapper;

import com.domain.Admin;
import com.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminMapper {

    // 根据ID查询后台用户
    @Select("SELECT * FROM t_admin WHERE id = #{id}")
    Admin findById(Integer id);

    // 插入后台用户
    @Insert("INSERT INTO t_admin(admin_name, pwd, phone) VALUES (#{adminName}, #{pwd}, #{phone})")
    int insertAdmin(Admin admin);

    // 更新后台用户
    @Update("UPDATE t_admin SET admin_name = #{adminName}, pwd = #{pwd}, phone = #{phone} WHERE id = #{id}")
    int updateAdmin(Admin admin);

    // 删除后台用户（根据ID）
    @Delete("DELETE FROM t_admin WHERE id = #{id}")
    int deleteAdminById(Integer id);

    // 查询所有后台用户
    @Select("SELECT * FROM t_admin")
    List<Admin> findAllAdmins();

    // 根据用户名和密码查询后台用户（用于登录）
    @Select("SELECT * FROM t_admin WHERE admin_name = #{adminName} AND pwd = #{pwd}")
    public Admin userLogin(Admin Admin);

//    @Select("SELECT * FROM t_admin WHERE admin_name=#{adminName} and pwd=#{pwd}")
//    public Admin userLogin(Admin Admin);
}